import React, { Component } from 'react'

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      message: "hello world",
      name: "codewhy",
    }
  }
  render() {
    return (
      <div>
        <h2>{this.state.message}</h2>
        <h2>{this.state.name}</h2>
        <button onClick={e => this.chengeText()}>改变文本</button>
      </div>
    )
  }

  chengeText() {
    this.setState({
      message: "你好"
    })
    console.log(this.state.name);

    // Object.assign({}, this.state, { message: "你好" })

  }
}
